<template>
	<view class="edit-order">
		<u-form :model="receiptInfoData" label-width="200rpx">
			<u-form-item label="订单号:"><u-input v-model="receiptInfoData.orderNo" type="text" placeholder="请输入订单号" /></u-form-item>
			<u-form-item label="收货地址:"><u-input v-model="receiptInfoData.deliveryStreet" type="text" placeholder="请输入收货地址" /></u-form-item>
			<u-form-item label="收货人电话:"><u-input v-model="receiptInfoData.deliveryMobile" type="text" placeholder="请输入收货人电话:" /></u-form-item>
			<u-form-item label="收货人姓名:"><u-input v-model="receiptInfoData.deliveryName" type="text" placeholder="请输入收货人姓名" /></u-form-item>
			<u-button style="margin: 125rpx 50rpx 0 50rpx;" type="primary" shape="circle" @click="submit">确定修改</u-button>
		</u-form>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderNo: '',
				receiptInfoData: {
					"deliveryMobile": "",
					"deliveryName": "",
					"deliveryStreet": "",
					"id": '',
					"orderNo": ""
				},
			}
		},
		onLoad(option) {
			this.orderNo = option.orderNo;
			this.getDetail()
		},
		methods: {
			getDetail() {
				this.$u.api.getmallOrderDetails({
					orderNo: this.orderNo,
				}).then(res=>{
					if(res.code == 0){
						this.receiptInfoData = {
							"deliveryMobile": res.data.order.deliveryMobile,
							"deliveryName": res.data.order.deliveryName,
							"deliveryStreet": res.data.order.deliveryStreet,
							"id": res.data.order.id,
							"orderNo": res.data.order.orderNo
						}
					}else{
						uni.showToast({
							icon:'none',
							title: res.msg
						});
					}
				})
			},
			submit() {
				this.$u.api.putMallOrderUpdate(this.receiptInfoData).then(res=>{
					if(res.code == 0){
						uni.showToast({
							icon:'none',
							title: '修改成功'
						});
					}else{
						uni.showToast({
							icon:'none',
							title: res.msg
						});
					}
				})
			}
		}
	}
</script>

<style scoped>
.edit-order {
	padding: 0 30rpx;
}
</style>
